package 数组变换;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int flag = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            flag = Math.max(flag, a[i]);
        }
        for (int i = 0; i < n; i++) {
            if (flag % a[i] != 0) {
                System.out.println("NO");
                return;
            }
            int x = flag / a[i];
            if ((x & (x - 1)) != 0) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}
